package com.yyq.gxdc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yyq.gxdc.entity.ReceivingAddress;
import com.yyq.gxdc.mapper.ReceivingAddressMapper;
import com.yyq.gxdc.service.IReceivingAddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ReceivingAddressServiceImpl extends ServiceImpl<ReceivingAddressMapper, ReceivingAddress> implements IReceivingAddressService {
    @Resource
    private ReceivingAddressMapper receivingAddressMapper;

    @Override
    public PageInfo<ReceivingAddress> findPage(ReceivingAddress conditioin, int pageNum, int pageSize) {
        return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> {
            receivingAddressMapper.find(conditioin);
        });
    }
    @Override
    public int add(ReceivingAddress receivingAddress) {
        return receivingAddressMapper.insert(receivingAddress);
    }
    @Override
    public ReceivingAddress findById(Integer id) {
        return receivingAddressMapper.findById(id);
    }

    @Override
    public ReceivingAddress getDetailByRid(Integer rid){
        ReceivingAddress receivingAddress = receivingAddressMapper.findById(rid);

        return receivingAddress;
    }

    @Override
    public int update(ReceivingAddress receivingAddress) {
        return receivingAddressMapper.updateById(receivingAddress);
    }
    @Override
    public int delete(Integer id) {
        return receivingAddressMapper.deleteById(id);
    }

    @Override
    public IPage<ReceivingAddress> getAllReceivingAddress(Page<ReceivingAddress> page, ReceivingAddress conditioin){
        return receivingAddressMapper.getAllReceivingAddress(page,conditioin);
    };
}

